/*
 * @Description: 悟空软件
 * @Author: 悟空
 * @Date: 2020-05-14 13:58:52
 * @LastEditTime: 2020-07-01 10:02:41
 * @LastEditors: yang
 */
import request from '@/utils/request'

/**
 * 部门列表
 * @param {*} data
 */
export function hrmDeptQueryTreeListAPI(data) {
  return request({
    url: 'hrmDept/queryTreeList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 部门Map
 */
export function hrmDeptQueryNameMapAPI() {
  return request({
    url: 'hrmDept/queryDeptNameMap',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 员工数据推送
 * @param {*} data
 */
export function hrmDeptPushDataByIdsAPI(data) {
  return request({
    url: 'hrmDept/pushData',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 部门新建
 * @param {*} data
 */
export function hrmDeptAddDeptAPI(data) {
  return request({
    url: 'hrmDept/addDept',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 部门部门
 * @param {*} data
 */
export function hrmDeptSetDeptAPI(data) {
  return request({
    url: 'hrmDept/setDept',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 查询部门详情
 * @param {*} data
 */
export function hrmDeptQueryByIdAPI(id) {
  return request({
    url: `hrmDept/queryById/${id}`,
    method: 'post'
  })
}

/**
 * 查询部门删除
 * @param {*} data
 */
export function hrmDeptDeleteByIdAPI(id) {
  return request({
    url: `hrmDept/deleteDeptById/${id}`,
    method: 'post'
  })
}

/**
 * 通过部门id查询员工列表
 * @param {*} data
 */
export function hrmDeptQueryEmployeeAPI(data) {
  return request({
    url: 'hrmDept/queryEmployeeByDeptId',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 组织负责人、分管领导列表
 * @param {*} data
 */
export function hrmDeptQueryManageEmployeeAPI(data) {
  return request({
    url: 'hrmDept/queryManageEmployeeByDeptId',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 获取子部门部门数量
 * @param deptId
 * @returns {*}
 */
export function hrmDeptChildrenCountAPI(deptId) {
  return request({
    url: `hrmDept/childrenCount/${deptId}`,
    method: 'get'
  })
}

/**
 * 部门数据推送
 */
export function hrmDeptPushDataAPI() {
  return request({
    url: 'hrmDept/dataSync',
    method: 'get'
  })
}

/**
 * 部门导出列表
 */
export function exportHrmDeptListAPI() {
  return request({
    url: 'hrmDept/exportDeptList',
    method: 'get'
  })
}

/**
 * 部门导出
 */
export function exportHrmDeptAPI(data) {
  return request({
    url: 'hrmDept/export',
    method: 'post',
    responseType: 'blob',
    data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}


export function hrmEmployeeDataTotalAPI(data) {
  return request({
    url: 'hrmDept/employeeDataTotal',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function hrmOrgEmployeeChangeAPI() {
  return request({
    url: 'hrmDept/updateComprehensiveDept',
    method: 'get',
  })
}

/**
 * 员工数据完整性查询
 * @param {*} data
 */
export function hrmEmployeeDataIntegrityAPI(data) {
  return request({
    url: '/hrmEmployeeDataIntegrity/queryEmployeeDataIntegrity',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 员工数据修改数查询
 * @param {*} data
 */
export function hrmEmployeeChangeRecordAPI(data) {
  return request({
    url: '/hrmEmployeeDataChangeRecord/queryPageList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 员工异动频次性查询
 * @param {*} data
 */
export function hrmEmployeeMobilizeRecordAPI(data) {
  return request({
    url: '/hrmEmployeeDataMobilizeRecord/queryPageList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}


/**
 * 部门导入
 * @param {*} data
 */
export function deptExcelImportAPI(data) {
  const param = new FormData()
  Object.keys(data).forEach(key => {
    param.append(key, data[key])
  })
  return request({
    url: 'hrmDept/excelImport',
    method: 'post',
    data: param,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * 获取导入模板
 * @param {*} data
 */
export function deptImportTemplateAPI() {
  return request({
    url: 'hrmDept/downloadExcel',
    method: 'post',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 下载用户导入错误数据
 * @param {*} data
 *
 */
export function deptErrorExcelDownAPI(data) {
  return request({
    url: 'hrmDept/downExcel',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}

